<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <!--<script type="text/javascript" src="<?php echo Yii::app()->baseUrl ?>/assets/js/jquery-1.7.2.min.js"></script>-->
        <!--<script type="text/javascript" src="<?php echo Yii::app()->baseUrl ?>/assets/js/jquery-ui-1.10.3.min.js"></script>-->
        
        <!--js for validator && elfinder (REQUIRED)-->
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl?>/assets/js/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl ?>/assets/js/jquery-1.7.2.min.js"></script> 
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl?>/assets/js/bootstrapValidator.min.js"></script>
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl."/assets/js/bootstrap.min.js" ?>"></script>
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl ?>/assets/js/jquery-ui-1.10.3.min.js"></script>
        <!--elFinder CSS (REQUIRED)--> 
        <link rel="stylesheet" type="text/css" media="screen" href="<?php echo Yii::app()->baseUrl ?>/css/elfinder.min.css">
        <link rel="stylesheet" type="text/css" media="screen" href="<?php echo Yii::app()->baseUrl ?>/css/theme.css">
        
        <!--elFinder JS (REQUIRED)--> 
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl ?>/js/elfinder.min.js"></script>
        
        <!--elFinder translation (OPTIONAL)--> 
       <!--<script type="text/javascript" src="<?php echo Yii::app()->baseUrl ?>/js/i18n/elfinder.ru.js"></script>-->
        
        <!--elFinder initialization (REQUIRED)--> 
        <script type="text/javascript" charset="utf-8">
            $().ready(function() {
            });
        </script>
        
        <!--my custom-->
        <link rel="stylesheet" type="text/css" media="screen" href="<?php echo Yii::app()->baseUrl ?>/assets/css/mycustom.css">
        <title>SalePoint Edit</title>
    </head>
    <body>
        <div id="main-container" class="main-container">
            <div id="breadcrumbs" class="breadcrumbs">
                <script type="text/javascript">
                    try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){};
                </script>
                <ul class="breadcrumb">
                    <li>
                        <i class="icon-home home-icon"></i>
                        <a href=".."><strong>Trang Chủ</strong></a>
                    </li>
                    <li>
                        <a href="../site/salepoint"><strong>Thương Hiệu</strong></a>
                    </li>
                    <li>
                        <strong>Chỉnh Sửa Thông Tin Thương Hiệu</strong>
                    </li>
                </ul><!-- .breadcrumb -->
                
                <div id="nav-search" class="nav-search">
                    <form class="form-search">
                        <span class="input-icon">
                            <input type="text" autocomplete="off" id="nav-search-input" class="nav-search-input" placeholder="Search ...">
                            <i class="icon-search nav-search-icon"></i>
                        </span>
                    </form>
                </div><!-- #nav-search -->
            </div>    
            
            <div class="page-content">
                <div class="page-header">
                    <h1><strong> Chỉnh Sửa Thông Tin Thương Hiệu</strong></h1>
                </div><!-- /.page-header -->
                <div class="row">
                    <div class="col-xs-12">
                        <form id="idFormAdd" class="form-horizontal" method="POST">
                            <?php $form=$this->beginWidget('CActiveForm', array(
                                'htmlOptions' => array(
                                    'enctype' => 'multipart/form-data',
                                ),              
                            ));?>
                        <!--<fieldset>-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right">
                                    Tên cửa hàng <font class="red">*</font>
                                </label>
                                <div class="col-sm-10 col-sm-5">
                                    <input class="form-control" type="text" name="SalePointForm[sale_name]" id="SalePointForm_name" value="<?php echo $rows_salepoint[0]["sale_name"];?>"></input>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'mobile');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                    Số điện thoại <font class="red">*</font>
                                </label>
                                <div class="col-xs-10 col-sm-5">
                                    <input class="form-control" type="text" name="SalePointForm[sale_mobile]" id="SalePointForm_mobile" value="<?php echo $rows_salepoint[0]["sale_mobile"]?>"></input>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'adress');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                    Địa chỉ <font class="red">*</font>
                                </label>
                                <div class="col-xs-10 col-sm-5">
                                    <input class="form-control" type="text" name="SalePointForm[sale_address]" id="SalePointForm_address" value="<?php echo $rows_salepoint[0]["sale_address"]?>"></input>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                             <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">
                            Email <font class="red">*</font>
                        </label>
                        <div class="col-xs-10 col-sm-5">
                            <input class="form-control" value="<?php echo $rows_salepoint[0]["sale_email"]?>" type="text" name="SalePointForm[sale_email]" id="SalePointForm_email"/>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'adress');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                    Quốc Gia
                                </label>
                                <div class="col-xs-10 col-sm-5">
                                    <input class="form-control" type="text" name="SalePointForm[sale_country]" id="SalePointForm_country" value="<?php echo $rows_salepoint[0]["sale_country"]?>"></input>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'adress');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                     Mã Quốc Gia
                                </label>
                                <div class="col-xs-10 col-sm-5">
                                    <input class="form-control" type="text" name="SalePointForm[sale_country_code]" id="SalePointForm_countrycode" value="<?php echo $rows_salepoint[0]["sale_country_code"]?>"/>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'adress');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                    Khu vực <font class="red">*</font>
                                </label>
                                <div class="col-sm-10 col-sm-5" id="area">
                                    <select class="form-control" name="SalePointForm[sale_area]" id="SalePointForm_area">
                                            <option value="0">Chọn thành phố</option>
                                            <?php foreach ($model->arrArea as $key => $value) {
                                                $key++;
                                                if ($value == $rows_salepoint[0]["sale_area"])
                                                    echo "<option value='$key' selected>".$value."</option>";
                                                else                                                    
                                                    echo "<option value='$key'>".$value."</option>";
                                                }?>
                                    </select>
                        </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'adress');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                    Quận/Huyện <font class="red">*</font>
                                </label>
                                <div class="col-sm-10 col-sm-5" id="district">
                                    <select class="form-control" name="SalePointForm[sale_district]" id="SalePointForm_district">
                                        <option value="<?php echo $rows_salepoint[0]["sale_district"]?>"><?php echo $rows_salepoint[0]["sale_district"]?></option>
                                    </select>
                        </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'lat');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                    Latitue
                                </label>
                                <div class="col-xs-10 col-sm-5">
                                    <input class="form-control" type="text" name="SalePointForm[lat]" id="SalePointForm_lat" value="<?php echo $rows_salepoint[0]["sale_lat"]?>"></input>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'log');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                    Longtitue
                                </label>
                                <div class="col-xs-10 col-sm-5">
                                    <input class="form-control" type="text" name="SalePointForm[lng]" id="SalePointForm_lng" value="<?php echo $rows_salepoint[0]["sale_lng"]?>"></input>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right">
                                    Loại hình kinh doanh <font class="red">*</font>
                                </label>
                                <div class="col-sm-10 col-sm-5" id="business">
                                    <select class="form-control" name="SalePointForm[sale_business]" id="SalePointForm_business">
                                            <option value="0">Chọn loại cửa hàng</option>
                                            <?php foreach ($data_business as $key => $value) {
                                                $key++;
                                                if ($value['id'] == $rows_salepoint[0]["sale_business"])
                                                    echo "<option value='$key' selected>".$value['name']."</option>";
                                                else
                                                    echo "<option value='$key'>".$value['name']."</option>";
                                                }?>
                                    </select>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group">
                        <?php // echo $form->error($model,'adress');?>
                                <label class="col-sm-2 control-label no-padding-right">
                                     Xếp hạng
                                </label>
                                <div class="col-xs-10 col-sm-5">
                                    <input class="form-control" type="text" name="SalePointForm[sale_rating]" id="SalePointForm_rating" value="<?php echo $rows_salepoint[0]["sale_rating"]?>"></input>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="space-6"></div>
                            
                            <div class="form-group"> 
                                <label class="col-sm-2 control-label no-padding-right">
                                    Ảnh <font class="red">*</font>
                                </label>
                                <div class="col-xs-10 col-sm-5" >
                            <?php  if($rows_salepoint[0]["sale_image"] != NULL){ ?>
                                    <img src="../../files/<?php echo $rows_salepoint[0]['sale_image'];?>" onclick="imageClick();" id="LinkImage" name="LinkImage" style="max-height: 600px; max-width: 800px;"/>
                             <?php } else {?>
                                    <img src="../../images/photo.png" onclick="imageClick();" id="LinkImage" name="LinkImage" style="max-height: 600px; max-width: 800px;"/>
                             <?php }?>
                                    <input type="hidden" id="SalePointForm_image" name="SalePointForm[sale_image]" type="text"/>
                                    <p class="help-block">                                
                                        Image must be more than 100x100px and smaller than 4MB
                                    </p>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-2 col-md-10">
                                    <button class="btn btn-sm btn-primary" type="submit">
                                        <i class="icon-save align-top bigger-125"></i>
                                        Save
                                    </button>
                                    <a class="btn btn-sm" type="button" href="../site/salepoint">
                                        Back
                                        <i class="icon-backward align-top bigger-125"></i>
                                    </a>
                                </div>
                            </div>
            <?php $this->endWidget(); ?>
                                                </form>
                    </div>
                </div>
                
            </div>
        </div>
        <script type="text/javascript" charset="utf-8">
            function imageClick(){
                $( "#dialog-message" ).dialog({
                    title:"",
                    height:600,
                    width:1100,
                    modal: true
                });					
                var elf = $('#elfinder').elfinder({
                    url : '<?php echo Yii::app()->baseUrl ?>/php/connector.php' // connector URL (REQUIRED)
                    ,lang: 'en',
                    width:'100%',
                    commandsOptions: {
                        getfile: {
                            oncomplete: 'destroy' 
                        }
                    },
                    getFileCallback: function(file) {
                        $('#LinkImage').attr('src',file);
                        $('#SalePointForm_image').attr('value',file);
                        $( "#dialog-message" ).dialog( "close" );
                    }
                }).elfinder('instance'); 
                
            };
                
        </script>
        <!--my custom-->
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl ?>/assets/js/mycustom.js"> </script>
        <div id="dialog-message" >
            <div id="elfinder"></div>
        </div>
        <script type="text/javascript">       
    $(document).ready(function() {
        $("#idFormAdd").bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                'SalePointForm[sale_name]':{ 
                    message: 'The sale name is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The sale name is required'
                        }
                    },
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: 'The username must be more than 6 and less than 30 characters long'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9]+$/,
                        message: 'The username can only consist of alphabetical and number'
                    },
                },
                'SalePointForm[sale_address]': {
                    message: 'The address is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The address is required and cannot be empty'
                        },
                        stringLength: {
                            min: 6,
                            max: 100,
                            message: 'The address must be more than 6 and less than 30 characters long'
                        },
                    }
                },
                'SalePointForm[sale_country]': {
                    message: 'The country is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The country is required and cannot be empty'
                        },                    
                    }
                },
                'SalePointForm[sale_country_code]': {
                    validators: {
                        notEmpty: {
                            message: 'The country code is required and cannot be empty'
                        },                    
                    }
                },
                'SalePointForm[sale_area]': {
                    message: 'The area is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The area is required and cannot be empty'
                        },                    
                    }
                },
                'SalePointForm[sale_district]': {
                    message: 'The district is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The district is required and cannot be empty'
                        },                   
                    }
                },
                'SalePointForm[sale_lat]': {
                    message: 'The value is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The value is required and cannot be empty'
                        },
                        regexp: {
                            regexp: /^(\d*)(?:.(?:\d{0,2}))$/,
                            message: 'The value is not an number'
                        },
                    }
                },
                'SalePointForm[sale_lng]': {
                    message: 'The value is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The value is required and cannot be empty'
                        },
                        regexp: {
                            regexp: /^(\d*)(?:.(?:\d{0,2}))$/,
                            message: 'The value is not an number'
                        },
                    }
                },
                'SalePointForm[sale_business]': {
                    message: 'The business is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The business is required and cannot be empty'
                        }                        
                    }
                },
                'SalePointForm[sale_rating]': {
                    message: 'The rating is not valid',
                    validators: {
                        integer: {
                            message: 'The value is not an integer'
                        },
                        notEmpty: {
                            message: 'The rating is required and cannot be empty'
                        }
                        
                    }
                },
                'SalePointForm[sale_mobile]': {
                    message: 'The mobile is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The mobile is required and cannot be empty'
                        },
                        stringLength: {
                            min: 6,
                            max: 30,
                            message: 'The mobile must be more than 6 and less than 30 characters long'
                        },
                        digits: {
                            message: 'The phone number can contain digits only'
                        },
                    }
                },
                'SalePointForm[sale_email]': {
                    message: 'The email is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The email address is required and cannot be empty'
                        },
                        emailAddress: {
                            message: 'The email address is not a valid'
                        }
                    }
                },
                'SalePointForm[sale_image]': {
                    message: 'The image is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The image is required and cannot be empty'
                        },                    
                    }
                },
            }
        });        
    });
</script>
    </body>
</html>
